package com.dmwork.service.message.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dmwork.service.message.entity.FeedFollowMessage;
import com.dmwork.service.message.mapper.FeedFollowMessageMapper;
import com.dmwork.service.message.service.FeedFollowMessageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户动态推送表 服务实现类
 * </p>
 *
 * @author 李天
 * @since 2021-04-27
 */
@Service
public class FeedFollowMessageServiceImpl extends ServiceImpl<FeedFollowMessageMapper, FeedFollowMessage> implements FeedFollowMessageService {

    @Override
    public Integer getUnreadFeedCount(String followerId) {
        QueryWrapper<FeedFollowMessage> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("follower_id", followerId).eq("read_status", 0);
        return baseMapper.selectCount(queryWrapper);
    }

    @Override
    public void setReadFeedByCustomerId(String customerId) {
        QueryWrapper<FeedFollowMessage> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("follower_id", customerId).eq("read_status", 0);
        FeedFollowMessage feedFollowMessage = new FeedFollowMessage();
        feedFollowMessage.setReadStatus(1);
        baseMapper.update(feedFollowMessage, queryWrapper);
    }
}
